﻿//********************************************************************************//
//创建日期：<创建日期，2016-09-13>
//创建作者：<孙雪婷，sunxueting@shanghai3h.com>
//功能说明：业务员调动
//********************************************************************************//
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Entity;
using BLL;
using BLL.Access;
using System.Data;
using Platform.Http;
using Web.Class;

namespace Web.Pages.QuShui.DiXiaS._2.YongHuGL
{
    public partial class YeWuYDD : System.Web.UI.Page
    {
        #region 属性

        #endregion

        #region 变量

        /// <summary>
        /// 数据访问操作类
        /// </summary>
        SpHelper _spHelper = new SpHelper();

        /// <summary>
        /// 日志BLL
        /// </summary>
        SYS_LOGBLL _SYS_LOGBLL = new SYS_LOGBLL();

        #endregion

        #region 事件

        /// <summary>
        /// 页面加载事件
        /// </summary>
        protected void Page_Load(object sender, EventArgs e)
        {
            //第一次页面加载
            if (!IsPostBack)
            {
                InitControl();
            }
        }

        /// <summary>
        /// 响应前台回调
        /// </summary>
        protected void ASPxCallback1_Callback(object source, DevExpress.Web.CallbackEventArgs e)
        {
            if (e.Parameter == "tab1")
            {
                _spHelper.P_YS_UPDATE_JUGLK_YWY(null, Convert.ToInt32(this.cmbMuDiYWY.Value), null, 0, LoginInfo.CurrentUser.UserID.ToString(), DateTime.Now, Convert.ToInt32(this.cmbYuanYWY.Value));
            }
            else if (e.Parameter == "tab2")
            {
               // _spHelper.P_YS_UPDATE_JUGLK_YWY(this.cmbJu.Value.ToString(), Convert.ToInt32(this.cmbJuMuDiYWY.Value), null, 1, LoginInfo.CurrentUser.UserID.ToString(), DateTime.Now, null);
            }
           
            e.Result = e.Parameter + "|0|操作成功！";
        }

      
        #endregion

        #region 方法

        /// <summary>
        /// 初始化控件
        /// </summary>
        private void InitControl()
        {
            //根据操作人获取站点
            DataTable dtZhanDian = BusinessTool.GetTextAndValue("View_AS_UserInfo", "ZHANDIANMC", "ZHANDIANBH", null, string.Format("USERID={0}", LoginInfo.CurrentUser.UserID)).Tables[0];
            string zhendianBH = dtZhanDian.Rows[0]["VALUE"].ToString();
            //***加载用户业务员修改***//
            //加载当前所有用户正使用的业务员
            PageTools.BindComboBox(
                this.cmbYuanYWY, BusinessTool.GetTextAndValue(
                    "view_as_userinfo", "USERNAME", "USERID", "-", "USERID in (select S_YEWUY from YS_YG_YONGHUXX where I_JLZT=0)"
                ).Tables[0]
            );
            this.cmbYuanYWY.Value = "";
            //获取所有业务员
            DataTable ywyAll = BusinessTool.GetTextAndValue("View_AS_UserInfo", "USERNAME", "USERID", "-", string.Format("ROLENAME like '%业务员%'")).Tables[0];
            //加载所有业务员
            PageTools.BindComboBox(this.cmbMuDiYWY, ywyAll);
            if (this.cmbMuDiYWY.Items.Count != 0)
            {
                this.cmbMuDiYWY.SelectedIndex = 0;
            }
            this.cmbMuDiYWY.Value = "";
            //***加载局业务员修改***//
            //加载局
            PageTools.BindComboBox(
                this.cmbJu, BusinessTool.GetTextAndValue(
                    "QS_JX_XINGZHENGQ", "S_XINGZHENGQM", "S_XINGZHENGQH", "-", "i_jlzt=0"
                ).Tables[0]
            );
            this.cmbJu.Value = "";
            //加载所有业务员
            PageTools.BindComboBox(this.cmbJuMuDiYWY, ywyAll);
            this.cmbJuMuDiYWY.Value = "";

        }

        #endregion        
    }
}